package com.bit.ioc.controller;

import com.bit.ioc.config.UserConfig;
import com.bit.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2025-11-19
 * Time: 10:43
 */

@Controller("hello")
public class HelloController {



    //HelloController里有这个依赖，通过@Autowired来注入
    //属性注入
//    @Autowired
//    private UserService us;
//    private UserConfig userConfig;
//
//
//    //属性注入
//    public HelloController(UserService us) {
//        this.us = us;
//    }
//
//    @Autowired
//    public HelloController(UserService us, UserConfig userConfig) {
//        this.us = us;
//        this.userConfig = userConfig;
//    }

    //setter方法注入

    private UserService us;
    private UserConfig userConfig;


    @Autowired
    public void setUs(UserService us) {
        this.us = us;
    }

    @Autowired
    public void setUserConfig(UserConfig userConfig) {
        this.userConfig = userConfig;
    }

    public void print(){
        System.out.println("do Controller");
        us.print();
        userConfig.print();
    }
}
